Derived expression types

This section gives rewrite rules for the derived expression types. By the application of these rules, any expression can be reduced to a semantically equivalent expression in which only the primitive expression types (literal, variable, call, lambda, if, set!) occur.


\begin{schemenoindent}
(cond (\hyper{test} \hyper{sequence})
\hyperii{clause} \...
... '(d1 \dotsfoo)) (thunk1))
\dotsfoo
(else (elsethunk))))%
\end{schemenoindent}
where memv is an expression evaluating to the memv procedure.


\begin{schemenoindent}
(and) \=\hbox to 2em{\hfil $\equiv$}\schtrue
(and \hyper{...
...\hyperi{variable} \hyperi{temp})
\dotsfoo)
\hyper{body})%
\end{schemenoindent}
where temp, temp, are variables, distinct from variable, , that do not free occur in the original init expressions, and undefined is an expression which returns something that when stored in a location makes it an error to try to obtain the value stored in the location. (No such expression is defined, but one is assumed to exist for the purposes of this rewrite rule.) The second let expression in the expansion is not strictly necessary, but it serves to preserve the property that the init expressions are evaluated in an arbitrary order.


\begin{schemenoindent}
\par
(begin \hyper{sequence})
\hbox to 2em{\hfil $\equiv$}((lambda () \hyper{sequence}))%
\end{schemenoindent}
The following alternative expansion for begin does not make use of the ability to write more than one expression in the body of a lambda expression. In any case, note that these rules apply only if sequence contains no definitions.
\begin{schemenoindent}
(begin \hyper{expression})\hbox to 2em{\hfil $\equiv$}\hy...
...))
\hyper{command}
(lambda () (begin \hyper{sequence})))%
\end{schemenoindent}

The following expansion for do is simplified by the assumption that no step is omitted. Any do expression in which a step is omitted can be replaced by an equivalent do expression in which the corresponding variable appears as the step.


\begin{schemenoindent}
(do ((\hyperi{variable} \hyperi{init} \hyperi{step})
\d...
...ep} \dotsfoo))))))
(\hyper{loop} \hyperi{init} \dotsfoo))%
\end{schemenoindent}
where loop is any variable which is distinct from variable, , and which does not occur free in the do expression.


\begin{schemenoindent}
(let \hyper{variable$_0$} ((\hyperi{variable} \hyperi{ini...
...uiv$}(\hyper{make-promise} (lambda () \hyper{expression}))%
\end{schemenoindent}
where make-promise is an expression evaluating to some procedure which behaves appropriately with respect to the force procedure; see section [*].